<?php
class BarangModel {

	private $uuid;
	private $kodeBarang;
	private $namaBarang;
	private $hargaBeli;
	private $hargaJual;
	private $kodeSupplier;
	private $merek;


	function __construct() {
		//payah nih ga support multiple constructor
	}

	function setPropertiesFromXmlArray($xmlArray) {
		$this->uuid = $xmlArray['uuid'];
		$this->kodeBarang = $xmlArray['kodeBarang'];
		$this->namaBarang = $xmlArray['namaBarang'];
		$this->hargaJual = $xmlArray['hargaJual'];
		$this->hargaBeli = $xmlArray['hargaBeli'];
		$this->kodeSupplier = $xmlArray['kodeSupplier'];
		$this->merek = $xmlArray['merek'];
	}

	function setPropertiesFromValue($uuid, $kodeBarang, $namaBarang, $hargaBeli, $hargaJual, $kodeSupplier, $merek) {
		$this->uuid = $uuid;
		$this->kodeBarang = $kodeBarang;
		$this->namaBarang = $namaBarang;
		$this->hargaJual = $hargaJual;
		$this->hargaBeli = $hargaBeli;
		$this->kodeSupplier = $kodeSupplier;
		$this->merek = $merek;
	}

	public function setUuid($uuid) {
		$this->uuid = $uuid;
	}

	public function getUuid() {
		return $this->uuid;
	}

	public function setKodeBarang($kodeBarang) {
		$this->kodeBarang = $kodeBarang;
	}

	public function getKodeBarang() {
		return $this->kodeBarang;
	}

	public function setNamaBarang($namaBarang) {
		$this->namaBarang = $namaBarang;
	}

	public function getNamaBarang() {
		return $this->namaBarang;
	}

	public function setHargaBeli($hargaBeli) {
		$this->hargaBeli = $hargaBeli;
	}

	public function getHargaBeli() {
		return $this->hargaBeli;
	}

	public function setHargaJual($hargaJual) {
		$this->hargaJual = $hargaJual;
	}

	public function getHargaJual() {
		return $this->hargaJual;
	}

	public function setKodeSupplier($kodeSupplier) {
		$this->kodeSupplier = $kodeSupplier;
	}

	public function getKodeSupplier() {
		return $this->kodeSupplier;
	}

	public function setMerek($merek) {
		$this->merek = $merek;
	}

	public function getMerek() {
		return $this->merek;
	}
	
	public function getXmlDocument() {
		$document = new DOMDocument('1.0', 'UTF-8');
		$elementBarang = $document->createElement('barang');
		$elementUuid = $document->createElement('uuid',$this->uuid);
		$elementKodeBarang = $document->createElement('kodeBarang',$this->kodeBarang);
		$elementNamaBarang = $document->createElement('namaBarang',$this->namaBarang);
		$elementHargaJual = $document->createElement('hargaJual',$this->hargaJual);
		$elementHargaBeli = $document->createElement('hargaBeli',$this->hargaBeli);
		$elementKodeSupplier = $document->createElement('kodeSupplier',$this->kodeSupplier);
		$elementMerek = $document->createElement('merek',$this->merek);
		
		$document->appendChild($elementBarang);
		$elementBarang->appendChild($elementUuid);
		$elementBarang->appendChild($elementKodeBarang);
		$elementBarang->appendChild($elementNamaBarang);
		$elementBarang->appendChild($elementHargaJual);
		$elementBarang->appendChild($elementHargaBeli);
		$elementBarang->appendChild($elementKodeSupplier);
		$elementBarang->appendChild($elementMerek);
		
		return $document->saveXML();
	}
}
